//package org.jeecg.modules.system.service.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import org.jeecg.modules.system.entity.ProUser;
////import org.jeecg.modules.system.mapper.SysUserExtMapper;
////import org.jeecg.modules.system.entity.SysUserExt;
////import org.jeecg.modules.system.service.ISysUserExtService;
//import org.jeecg.modules.system.service.ISysUserService;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.util.Date;
//
//@Service
//public class SysUserExtServiceImpl implements ISysUserExtService {
//    @Autowired
//    private SysUserExtMapper sysUserExtMapper;
//
//    @Autowired
//    private ISysUserService sysUserService;
//
//    @Override
//    public SysUserExt selectSysUserExt(SysUserExt sysUserExt) {
//        LambdaQueryWrapper<SysUserExt> wrapper = Wrappers.lambdaQuery(SysUserExt.class);
//        wrapper.eq(SysUserExt::getSysUserId, sysUserExt.getSysUserId());
//        SysUserExt ext = sysUserExtMapper.selectOne(wrapper);
//        if (ext == null) {
//            SysUserExt userExt = new SysUserExt();
//            ProUser user = sysUserService.getById(sysUserExt.getSysUserId());
//            BeanUtils.copyProperties(user,userExt);
//            userExt.setTitle(user.getPost());
//            userExt.setSysUserId(user.getId());
//            sysUserExtMapper.insert(userExt);
//            return userExt;
//        }
//        return ext;
//    }
//
//    @Override
//    public void saveOrUpdate(SysUserExt userExt) {
//        SysUserExt flag = selectSysUserExt(userExt);
//        if (flag == null) {
//            userExt.setUpdateTime(new Date());
//            userExt.setCreateTime(new Date());
//            ProUser user = sysUserService.getById(userExt.getSysUserId());
//            userExt.setUpdateBy(user.getRealname());
//            userExt.setCreateBy(user.getRealname());
//            sysUserExtMapper.insert(userExt);
//        } else {
//            userExt.setId(flag.getId());
//            userExt.setUpdateTime(new Date());
//            ProUser user = sysUserService.getById(userExt.getSysUserId());
//            userExt.setUpdateBy(user.getRealname());
//            sysUserExtMapper.updateById(userExt);
//            user.setPost(userExt.getTitle());
//            user.setPhone(userExt.getPhone());
//            user.setRealname(userExt.getRealname());
//            sysUserService.saveOrUpdate(user);
//        }
//    }
//}
